import Vue from 'vue'
import Router from 'vue-router'
var routerObj={}
var ua = navigator.userAgent;
var userInfoObj=''

function transferPrama(d){
	alert('transferPrama')
	setTimeout(function(){
		alert('transferPrama3000')
	},3000)
	userInfoObj = d||''
}
if(ua.match(/MicroMessenger/i) != 'MicroMessenger'){
	//不是微信，再分端
	routerObj={
		path: '/',
		name: 'index',
		redirect: 'index',
	}
	if((ua.match(/(Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone)/i))) {
		if(/iPhone|iPad|iPod/.test(ua)) {
			//'ios'
			
		} else if(/Android/.test(ua)) {
			//'android'
			// config.androidOrIosObj = JSON.parse(AndroidJsH5.H5JsData())
		}
	} else {
		//'pc'
		
	}
}else{
	//微信
	if(sessionStorage.getItem('wst_xiruixy_userInfo')&&sessionStorage.getItem('wst_xiruixy_userInfo')!='{}'){
		routerObj={
			path: '/',
			name: 'index',
			redirect: 'index',
		}
	}else{
		routerObj={
			path: '/',
			name: 'login',
			redirect: 'login',
		}
	}
}



//读取缓存
if(localStorage.getItem('wst_xiruixy_userInfo')&&localStorage.getItem('wst_xiruixy_userInfo')!='{}'){
	sessionStorage.setItem('wst_xiruixy_userInfo',localStorage.getItem('wst_xiruixy_userInfo'))
	routerObj={
		path: '/',
		name: 'index',
		redirect: 'index',
	}
}else{
	routerObj={
		path: '/',
		name: 'login',
		redirect: 'login',
	}
}


//获取channel_id
if(window.location.href.indexOf('?') >= 0 && window.location.search) {
	var urlParamsArr = window.location.href.split('?')[1].split('#/')[0].split('&')
	var obj = {}
	for(let a = 0; a < urlParamsArr.length; a++) {
		if(urlParamsArr[a].indexOf('=')) {
			obj[urlParamsArr[a].split('=')[0]] = urlParamsArr[a].split('=')[1]
		}
	}
	Object.assign(config, obj)
	if(config.params){
		var paramsObj={}
		for(let b=0 ; b < config.params.split('FG').length;b++){
			if(config.params.split('FG')[b].indexOf('DY')){
				paramsObj[config.params.split('FG')[b].split('DY')[0]]=config.params.split('FG')[b].split('DY')[1]
			}
		}
		Object.assign(config, paramsObj)
	}
}
//z这几个特殊的页面不需要登录
if(
	config.oldUrlStr=='articleDetail'||config.oldUrlStr=='productDetail'||config.oldUrlStr=='leaderDetail'||
	config.oldUrlStr=='teamTrendDetail'
){
	routerObj={
		path: '/',
		name: 'index',
		redirect: 'index',
	}
}


Vue.use(Router)
console.log(process.env.BASE_URL)
export default new Router({
	//mode: 'history',//这个模式需要后台一起配置才能使用
	base: process.env.BASE_URL, //应用的基路径。例如，如果整个单页应用服务在 /app/ 下，然后 base 就应该设为 "/app/"
	routes: [
		routerObj,
		{
			path: '/index',
			name:'index',
			component: () =>import( /* webpackChunkName: "index" */ '@/views/index/index.vue')
		},
		{
			path: '/login', //登录
			name: 'login',
			component: () =>import( /* webpackChunkName: "login" */ '@/views/login.vue')
		},
		//  {
		//    path: '/',
		//    name: 'home',
		////    component: Home //这种不是懒加载了
		//			component: () => import('@/views/Home.vue')
		//  },
		{
			path: '/live',//直播也详情页面
			name:'live',
			component: () =>import( /* webpackChunkName: "live" */ '@/views/live/live.vue')
		},
		{
			path: '/liveRoom',//直播
			name:'liveRoom',
			component: () =>import( /* webpackChunkName: "liveRoom" */ '@/views/liveRoom/liveRoom.vue')
		}, {
			path: '/liveRoomDetail',//直播过渡页
			name:'liveRoomDetail',
			component: () =>import( /* webpackChunkName: "liveRoomDetail" */ '@/views/liveRoomDetail/liveRoomDetail.vue')
		}, 
		//我的
		{
			path: '/my',//我的
			name:'my',
			component: () =>import( /* webpackChunkName: "my" */ '@/views/my/my.vue')
		},{
			path: '/myCollect',//我的收藏
			name:'myCollect',
			component: () =>import( /* webpackChunkName: "myCollect" */ '@/views/myCollect/myCollect.vue')
		},{
			path: '/myHeart',//我的心声
			name:'myHeart',
			component: () =>import( /* webpackChunkName: "myHeart" */ '@/views/myHeart/myHeart.vue')
		},{
			path: '/myHeartDetail',//我的心声详情
			name:'myHeartDetail',
			component: () =>import( /* webpackChunkName: "myHeartDetail" */ '@/views/myHeartDetail/myHeartDetail.vue')
		},{
			path: '/myStudy',//我的学习记录
			name:'myStudy',
			component: () =>import( /* webpackChunkName: "myStudy" */ '@/views/myStudy/myStudy.vue')
		},{
			path: '/myShareApp',//分享页面
			name:'myShareApp',
			component: () =>import( /* webpackChunkName: "myShareApp" */ '@/views/myShareApp/myShareApp.vue')
		},{
			path: '/set',//设置页面
			name:'set',
			component: () =>import( /* webpackChunkName: "set" */ '@/views/set/set.vue')
		},{
			path: '/vipOpen',//开通VIP
			name:'vipOpen',
			component: () =>import( /* webpackChunkName: "vipOpen" */ '@/views/vipOpen/vipOpen.vue')
		},{
			path: '/vipExchange',//兑换VIP
			name:'vipExchange',
			component: () =>import( /* webpackChunkName: "vipExchange" */ '@/views/vipExchange/vipExchange.vue')
		},{ 
			path: '/wallet',//钱包
			name:'wallet',
			component: () =>import( /* webpackChunkName: "wallet" */ '@/views/wallet/wallet.vue')
		},{
			path: '/pay',//支付
			name:'pay',
			component: () =>import( /* webpackChunkName: "pay" */ '@/views/pay/pay.vue')
		},{ 
			path: '/moneyWithdraw',//提现 
			name:'moneyWithdraw',
			component: () =>import( /* webpackChunkName: "moneyWithdraw" */ '@/views/moneyWithdraw/moneyWithdraw.vue')
		},{ 
			path: '/moneySuccess',//提现 成功
			name:'moneySuccess',
			component: () =>import( /* webpackChunkName: "moneySuccess" */ '@/views/moneySuccess/moneySuccess.vue')
		},{
			path: '/moneyDetail',//明细
			name:'moneyDetail',
			component: () =>import( /* webpackChunkName: "set" */ '@/views/moneyDetail/moneyDetail.vue')
		},{
			path: '/msgDetail',//金钱说明明细
			name:'msgDetail',
			component: () =>import( /* webpackChunkName: "msgDetail" */ '@/views/msgDetail/msgDetail.vue')
		},{
			path: '/success',//成功跳转的页面
			name:'success',
			component: () =>import( /* webpackChunkName: "success" */ '@/views/success/success.vue')
		},
		//首页
		{
			path: '/teamTrend',//团队动态列表
			name:'teamTrend',
			component: () =>import( /* webpackChunkName: "teamTrend" */ '@/views/teamTrend/teamTrend.vue')
		},{
			path: '/teamTrendDetail',//团队动态详情 
			name:'teamTrendDetail',
			component: () =>import( /* webpackChunkName: "teamTrendDetail" */ '@/views/teamTrendDetail/teamTrendDetail.vue')
		},{
			path: '/articleCompany',//聚焦公司文章 
			name:'articleCompany',
			component: () =>import( /* webpackChunkName: "articleCompany" */ '@/views/articleCompany/articleCompany.vue')
		},{
			path: '/articleIndustry',//行业知识文章
			name:'articleIndustry',
			component: () =>import( /* webpackChunkName: "articleIndustry" */ '@/views/articleIndustry/articleIndustry.vue')
		},{
			path: '/articleDetail',//文章详情 
			name:'articleDetail',
			component: () =>import( /* webpackChunkName: "articleDetail" */ '@/views/articleDetail/articleDetail.vue')
		},{
			path: '/teamLeader',//团队领袖 
			name:'teamLeader',
			component: () =>import( /* webpackChunkName: "teamLeader" */ '@/views/teamLeader/teamLeader.vue')
		},{
			path: '/leaderDetail',//领袖详情 
			name:'leaderDetail',
			component: () =>import( /* webpackChunkName: "leaderDetail" */ '@/views/leaderDetail/leaderDetail.vue')
		},{
			path: '/leaderHeart',//领袖详情 
			name:'leaderHeart',
			component: () =>import( /* webpackChunkName: "leaderHeart" */ '@/views/leaderHeart/leaderHeart.vue')
		},{
			path: '/productPresentation',//产品介绍 
			name:'productPresentation',
			component: () =>import( /* webpackChunkName: "productPresentation" */ '@/views/productPresentation/productPresentation.vue')
		},{
			path: '/productDetail',//产品介绍详情
			name:'productDetail',
			component: () =>import( /* webpackChunkName: "productDetail" */ '@/views/productDetail/productDetail.vue')
		},{
			path: '/search',//搜索页面
			name:'search',
			component: () =>import( /* webpackChunkName: "search" */ '@/views/search/search.vue')
		},
		//学习
		{
			path: '/study',//学习首页 
			name:'study',
			component: () =>import( /* webpackChunkName: "bd_index" */ '@/views/study/study.vue')
		},{
			path: '/message',//系统消息
			name:'message',
			component: () =>import( /* webpackChunkName: "message" */ '@/views/message/message.vue')
		},{
			path: '/messageIncome',//收入通知
			name:'messageIncome',
			component: () =>import( /* webpackChunkName: "messageIncome" */ '@/views/messageIncome/messageIncome.vue')
		},{
			path: '/messageOrder',//订单发货
			name:'messageOrder',
			component: () =>import( /* webpackChunkName: "messageOrder" */ '@/views/messageOrder/messageOrder.vue')
		},{
			path: '/messageMoney',//提现动态
			name:'messageMoney',
			component: () =>import( /* webpackChunkName: "messageMoney" */ '@/views/messageMoney/messageMoney.vue')
		},{
			path: '/courseClassical',//精品课
			name:'courseClassical',
			component: () =>import( /* webpackChunkName: "courseClassical" */ '@/views/courseClassical/courseClassical.vue')
		},{
			path: '/courseDetail',//课程详情
			name:'courseDetail',
			component: () =>import( /* webpackChunkName: "courseDetail" */ '@/views/courseDetail/courseDetail.vue')
		},{
			path: '/courseAudioDetail',//课程视频详情
			name:'courseAudioDetail',
			component: () =>import( /* webpackChunkName: "courseAudioDetail" */ '@/views/courseAudioDetail/courseAudioDetail.vue')
		},{
			path: '/allClass',//全部分类
			name:'allClass',
			component: () =>import( /* webpackChunkName: "allClass" */ '@/views/allClass/allClass.vue')
		},{
			path: '/liveList',//直播列表 
			name:'liveList',
			component: () =>import( /* webpackChunkName: "liveList" */ '@/views/liveList/liveList.vue')
		},{
			path: '/audioList',//音频列表
			name:'audioList',
			component: () =>import( /* webpackChunkName: "audioList" */ '@/views/audioList/audioList.vue')
		},{
			path: '/audioDetail',//音频列表
			name:'audioDetail',
			component: () =>import( /* webpackChunkName: "audioDetail" */ '@/views/audioDetail/audioDetail.vue')
		},{
			path: '/audioStudentShare',//视频学员分享
			name:'audioStudentShare',
			component: () =>import( /* webpackChunkName: "audioStudentShare" */ '@/views/audioStudentShare/audioStudentShare.vue')
		},
		
		//新人宝典
		{
			path: '/bd_index',//导航首页 
			name:'bd_index',
			component: () =>import( /* webpackChunkName: "bd_index" */ '@/views/bd/index/index.vue')
		},{
			path: '/bd_code',//输入激活码
			name:'bd_code',
			component: () =>import( /* webpackChunkName: "bd_code" */ '@/views/bd/code/code.vue')
		},{
			path: '/bd_goodsDetail',//商品详情
			name:'bd_goodsDetail',
			component: () =>import( /* webpackChunkName: "bd_goodsDetail" */ '@/views/bd/goodsDetail/goodsDetail.vue')
		},{
			path: '/bd_goodsOrder',//商品订单
			name:'bd_goodsOrder',
			component: () =>import( /* webpackChunkName: "bd_goodsOrder" */ '@/views/bd/goodsOrder/goodsOrder.vue')
		},{
			path: '/bd_goodsAddr',//商品收货地址
			name:'bd_goodsAddr',
			component: () =>import( /* webpackChunkName: "bd_goodsAddr" */ '@/views/bd/goodsAddr/goodsAddr.vue')
		},{
			path: '/bd_goodsSuccess',//商品收货地址
			name:'bd_goodsSuccess',
			component: () =>import( /* webpackChunkName: "bd_goodsSuccess" */ '@/views/bd/goodsSuccess/goodsSuccess.vue')
		},{
			path: '/bd_studyStage',//学习阶段页面，阶段课程目录
			name:'bd_studyStage',
			component: () =>import( /* webpackChunkName: "bd_studyStage" */ '@/views/bd/studyStage/studyStage.vue')
		},{
			path: '/bd_studyStageDetail',//学习阶段详情页面
			name:'bd_studyStageDetail',
			component: () =>import( /* webpackChunkName: "bd_studyStageDetail" */ '@/views/bd/studyStageDetail/studyStageDetail.vue')
		},{
			path: '/bd_studyStageDetailVideo',//学习阶段详情页面
			name:'bd_studyStageDetailVideo',
			component: () =>import( /* webpackChunkName: "bd_studyStageDetailVideo" */ '@/views/bd/studyStageDetailVideo/studyStageDetailVideo.vue')
		},{
			path: '/bd_comment',//评论列表
			name:'bd_comment',
			component: () =>import( /* webpackChunkName: "bd_studyStageDetail" */ '@/views/bd/comment/comment.vue')
		},{
			path: '/bd_share',//学习阶段详情页面
			name:'bd_share',
			component: () =>import( /* webpackChunkName: "bd_share" */ '@/views/bd/share/share.vue')
		},{
			path: '/bd_stageState',//阶段评测说明
			name:'bd_stageState',
			component: () =>import( /* webpackChunkName: "bd_share" */ '@/views/bd/stageState/stageState.vue')
		},{
			path: '/bd_stageList',//阶段评测记录
			name:'bd_stageList',
			component: () =>import( /* webpackChunkName: "bd_share" */ '@/views/bd/stageList/stageList.vue')
		},{
			path: '/bd_stageTopic',//阶段评测题目
			name:'bd_stageTopic',
			component: () =>import( /* webpackChunkName: "bd_stageTopic" */ '@/views/bd/stageTopic/stageTopic.vue')
		},{
			path: '/bd_result',//阶段评测题目
			name:'bd_result',
			component: () =>import( /* webpackChunkName: "bd_result" */ '@/views/bd/result/result.vue')
		},{
			path: '/bd_diploma',//领取毕业证
			name:'bd_diploma',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/bd/diploma/diploma.vue')
		},
		
		{
			path: '/faq',//常见问题
			name:'faq',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/faq/faq.vue')
		},
		{
			path: '/faqDetail',//常见问题详情
			name:'faqDetail',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/faqDetail/faqDetail.vue')
		},
		{
			path: '/faqQuestion',//提问
			name:'faqQuestion',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/faqQuestion/faqQuestion.vue')
		},
		{
			path: '/faqSuccess',//提问成功
			name:'faqSuccess',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/faqSuccess/faqSuccess.vue')
		},
		{
			path: '/byCyb',//榜样创业班
			name:'byCyb',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/byCyb/byCyb.vue')
		},
		{
			path: '/byBookrack',//榜样书架
			name:'byBookrack',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/byBookrack/byBookrack.vue')
		},
		{
			path: '/storeSystem',//系统商城
			name:'storeSystem',
			component: () =>import( /* webpackChunkName: "storeSystem" */ '@/views/storeSystem/storeSystem.vue')
		},
		{
			path: '/storeDetail',//商品详情
			name:'storeDetail',
			component: () =>import( /* webpackChunkName: "storeDetail" */ '@/views/storeDetail/storeDetail.vue')
		},
		{
			path: '/storeCar',//商品购物车
			name:'storeCar',
			component: () =>import( /* webpackChunkName: "storeCar" */ '@/views/storeCar/storeCar.vue')
		},
		{
			path: '/storeOrder',//商品订单页面
			name:'storeOrder',
			component: () =>import( /* webpackChunkName: "storeOrder" */ '@/views/storeOrder/storeOrder.vue')
		},
		{
			path: '/myOrder',//查看我的订单
			name:'myOrder',
			component: () =>import( /* webpackChunkName: "myOrder" */ '@/views/myOrder/myOrder.vue')
		},
		{
			path: '/storeAddr',//添加商品地址
			name:'storeAddr',
			component: () =>import( /* webpackChunkName: "storeAddr" */ '@/views/storeAddr/storeAddr.vue')
		},
		{
			path: '/storeSuccess',//添加商品地址
			name:'storeSuccess',
			component: () =>import( /* webpackChunkName: "storeSuccess" */ '@/views/storeSuccess/storeSuccess.vue')
		},
		{
			path: '/tool',//工具
			name:'tool',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/tool/tool.vue')
		},
		{
			path: '/orderList',//订单
			name:'orderList',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/orderList/orderList.vue')
		},
		{
			path: '/playList',//视频课堂列表
			name:'playList',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/playList/playList.vue')
		},
		{
			path: '/playListDetail',//视频课堂列表详情
			name:'playListDetail',
			component: () =>import( /* webpackChunkName: "bd_diploma" */ '@/views/playListDetail/playListDetail.vue')
		},
		{
			path: '/courseVideoDetail',//课程视频详情
			name:'courseVideoDetail',
			component: () =>import( /* webpackChunkName: "courseVideoDetail" */ '@/views/courseVideoDetail/courseVideoDetail.vue')
		},{
			path: '/courseVideoDetailVip',//精品课程课频详情
			name:'courseVideoDetailVip',
			component: () =>import( /* webpackChunkName: "courseVideoDetailVip" */ '@/views/courseVideoDetailVip/courseVideoDetailVip.vue')
		},{
			path: '/courseStage',//课程阶段目录
			name:'courseStage',
			component: () =>import( /* webpackChunkName: "courseStage" */ '@/views/courseStage/courseStage.vue')
		},
	]
})